<?php

require_once 'include/config.php';
require_once 'include/http.php';
require_once 'wechat.php';
$upload = new kefu();

class kefu{
    
    
    private $appid = '';
    private $appsecret = '';
    private $http = '';
    
    public function __construct() {
        $this->appid = constant('APPID');
        $this->appsecret = constant('APPSECRET');
        $this->http = new http();
        //获取access_token
        $wechat = new wechat();
        $this->access_token = $wechat->getAccessToken();
    }
    
    //发送客服消息
    public function sendMsg($openid,$msg) {
        $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$this->access_token}";
        $data = '{
            "touser":"'.$openid.'",
            "msgtype":"text",
            "text":
            {
                 "content":"'.$msg.'"
            }
        }';
//        echo $url;exit;
        return $this->http->http_request($url,$data);
    }
    
    
}

